      Subroutine EULER_Ghost
      include "param.fi"
      include "common.fi"

      Integer I

      If (Shepard .EQ. 1) Then
        Call Calc_ShepardCoef_Ghost
      Endif

      Call Calc_dRho_dT_Ghost
      Do I = 1, NTOT3T
        Rho(I) = Rho(I) + Temp1(I) * DT
        If (Rho(I).LT.RDENSITYMIN) Rho(I) = RDENSITYMIN
        If (Rho(I).GT.RDENSITYMAX) Rho(I) = RDENSITYMAX
      Enddo

      Call PressureField

      Do I = 1, NTOT3T
        ! Gravity
        U3(I) = U3(I) + Gravity * DT
      Enddo
      Call Calc_dU_dT_Ghost
      Do I = 1, NTOT3T - NPWALL
        U1(I) = U1(I) + Temp1(I) * DT
        If (DIMM.EQ.DIMM3D) U2(I) = U2(I) + Temp2(I) * DT
        U3(I) = U3(I) + Temp3(I) * DT
      Enddo

      If (ALE .EQ. ALEEuler) Then
        Call Grad_Ghost(U1, DU1DX, DU1DY, DU1DZ, 1)
        If (DIMM.EQ.DIMM3D) Call Grad_Ghost(U2, DU2DX, DU2DY, DU2DZ, 2)
        Call Grad_Ghost(U3, DU3DX, DU3DY, DU3DZ, 3)
        Call Calc_NLTerm
        Do I = 1, NTOT3T - NPWALL
          U1(I) = U1(I) + Temp1(I) * DT
          If (DIMM.EQ.DIMM3D) U2(I) = U2(I) + Temp2(I) * DT
          U3(I) = U3(I) + Temp3(I) * DT
        Enddo
      Endif

      Call Calc_VisTerm_Ghost
      Do I = 1, NTOT3T - NPWALL
        U1(I) = U1(I) + Temp1(I) * DT
        If (DIMM.EQ.DIMM3D) U2(I) = U2(I) + Temp2(I) * DT
        U3(I) = U3(I) + Temp3(I) * DT
      Enddo

      If (ALE .EQ. ALELagrange) Then
      ! Ghost condition
      If (tagAVERMOVE .EQ. 0) Then
      Do I = 1, NTOT3T - NPWALL
        X1(I) = X1(I) + U1(I) * DT
        If (X1(I).GT.XMAX) Then
          X1(I) = X1(I) - U1(I) * DT
          U1(I) = 0.5 * (XMAX-X1(I)) / DT
          X1(I) = X1(I) + 0.5 * (XMAX - X1(I))
        Endif
        If (X1(I).LT.XMIN) Then
          X1(I) = X1(I) - U1(I) * DT
          U1(I) = 0.5 * (X1(I)-XMIN) / DT
          X1(I) = X1(I) - 0.5 * (X1(I) - XMIN)
        Endif
        If (DIMM.EQ.DIMM3D) Then
          X2(I) = X2(I) + U2(I) * DT
          If (X2(I).GT.XMAX) Then
            X2(I) = X2(I) - U2(I) * DT
            U2(I) = 0.5 * (XMAX-X2(I)) / DT
            X2(I) = X2(I) + 0.5 * (XMAX - X2(I))
          Endif
          If (X2(I).LT.XMIN) Then
            X2(I) = X2(I) - U2(I) * DT
            U2(I) = 0.5 * (X2(I)-XMIN) / DT
            X2(I) = X2(I) - 0.5 * (X2(I) - XMIN)
          Endif
        Endif
        X3(I) = X3(I) + U3(I) * DT
        If (X3(I).GT.XMAX) Then
          X3(I) = X3(I) - U3(I) * DT
          U3(I) = 0.5 * (XMAX-X3(I)) / DT
          X3(I) = X3(I) + 0.5 * (XMAX - X3(I))
        Endif
        If (X3(I).LT.XMIN) Then
          X3(I) = X3(I) - U3(I) * DT
          U3(I) = 0.5 * (X3(I)-XMIN) / DT
          X3(I) = X3(I) - 0.5 * (X3(I) - XMIN)
        Endif
      Enddo
      Else
      Call AVER_GHOST(U1, TEMP1, 1)
      Call AVER_GHOST(U2, TEMP2, 1)
      Call AVER_GHOST(U3, TEMP3, 1)
      Do I = 1, NTOT3T - NPWALL
        X1(I) = X1(I) + TEMP1(I) * DT
        If (X1(I).GT.XMAX) Then
          X1(I) = X1(I) - TEMP1(I) * DT
          U1(I) = 0.5 * (XMAX-X1(I)) / DT
          X1(I) = X1(I) + 0.5 * (XMAX - X1(I))
        Endif
        If (X1(I).LT.XMIN) Then
          X1(I) = X1(I) - TEMP1(I) * DT
          U1(I) = 0.5 * (X1(I)-XMIN) / DT
          X1(I) = X1(I) - 0.5 * (X1(I) - XMIN)
        Endif
        If (DIMM.EQ.DIMM3D) Then
          X2(I) = X2(I) + TEMP2(I) * DT
          If (X2(I).GT.XMAX) Then
            X2(I) = X2(I) - TEMP2(I) * DT
            U2(I) = 0.5 * (XMAX-X2(I)) / DT
            X2(I) = X2(I) + 0.5 * (XMAX - X2(I))
          Endif
          If (X2(I).LT.XMIN) Then
            X2(I) = X2(I) - TEMP2(I) * DT
            U2(I) = 0.5 * (X2(I)-XMIN) / DT
            X2(I) = X2(I) - 0.5 * (X2(I) - XMIN)
          Endif
        Endif
        X3(I) = X3(I) + TEMP3(I) * DT
        If (X3(I).GT.XMAX) Then
          X3(I) = X3(I) - TEMP3(I) * DT
          U3(I) = 0.5 * (XMAX-X3(I)) / DT
          X3(I) = X3(I) + 0.5 * (XMAX - X3(I))
        Endif
        If (X3(I).LT.XMIN) Then
          X3(I) = X3(I) - TEMP3(I) * DT
          U3(I) = 0.5 * (X3(I)-XMIN) / DT
          X3(I) = X3(I) - 0.5 * (X3(I) - XMIN)
        Endif
      Enddo
      Endif

      If (tagRegroup .NE. 0) Then
        Call Regroup
      Endif

      Endif

      End Subroutine
